package com.module.oa.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.module.oa.domain.Performancestatistics;
import com.module.oa.service.IPerformancestatisticsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 绩效统计Controller
 * 
 * @author hezhengxian
 * @date 2023-09-12
 */
@RestController
@RequestMapping("/pcs")
public class PerformancestatisticsController extends BaseController
{
    @Autowired
    private IPerformancestatisticsService performancestatisticsService;

    /**
     * 查询绩效统计列表
     */
    @RequiresPermissions("performancestatistics:pcs:list")
    @GetMapping("/list")
    public TableDataInfo list(Performancestatistics performancestatistics)
    {
        startPage();
        List<Performancestatistics> list = performancestatisticsService.selectPerformancestatisticsList(performancestatistics);
        return getDataTable(list);
    }

    /**
     * 导出绩效统计列表
     */
    @RequiresPermissions("performancestatistics:pcs:export")
    @Log(title = "绩效统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Performancestatistics performancestatistics)
    {
        List<Performancestatistics> list = performancestatisticsService.selectPerformancestatisticsList(performancestatistics);
        ExcelUtil<Performancestatistics> util = new ExcelUtil<Performancestatistics>(Performancestatistics.class);
        util.exportExcel(response, list, "绩效统计数据");
    }

    /**
     * 获取绩效统计详细信息
     */
    @RequiresPermissions("performancestatistics:pcs:query")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Integer recordId)
    {
        return success(performancestatisticsService.selectPerformancestatisticsByRecordId(recordId));
    }

    /**
     * 新增绩效统计
     */
    @RequiresPermissions("performancestatistics:pcs:add")
    @Log(title = "绩效统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Performancestatistics performancestatistics)
    {
        return toAjax(performancestatisticsService.insertPerformancestatistics(performancestatistics));
    }

    /**
     * 修改绩效统计
     */
    @RequiresPermissions("performancestatistics:pcs:edit")
    @Log(title = "绩效统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Performancestatistics performancestatistics)
    {
        return toAjax(performancestatisticsService.updatePerformancestatistics(performancestatistics));
    }

    /**
     * 删除绩效统计
     */
    @RequiresPermissions("performancestatistics:pcs:remove")
    @Log(title = "绩效统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Integer[] recordIds)
    {
        return toAjax(performancestatisticsService.deletePerformancestatisticsByRecordIds(recordIds));
    }
}
